<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, user-scalable=no"
    />
    <title>运费订单</title>
    <link
      rel="stylesheet"
      href="https://pyzl-static.oss-cn-guangzhou.aliyuncs.com/vendor/vant_2.12.54.css"
    />
    <style>
      /* 页面容器 */
      .page-container {
        padding: 0;
        height: 100vh;
        box-sizing: border-box;
        background-color: #f5f5f5;
        display: flex;
        flex-direction: column;
      }

      /* 头部标题样式 */
      .header {
        padding: 12px 16px;
        background-color: #fff;
        border-bottom: 1px solid #eee;
        position: relative;
      }

      .header-title {
        font-size: 18px;
        font-weight: 500;
        color: #333;
        text-align: center;
      }

      /* 标签页样式 */
      .tabs-container {
        background-color: #fff;
        border-bottom: 1px solid #eee;
        margin-bottom: 10px;
      }

      .tabs-wrapper {
        display: flex;
        overflow-x: auto;
        padding: 0 8px;
        position: absolute;
        top: 0;
        left: 0;
      }

      .tab-item {
        padding: 12px 16px;
        white-space: nowrap;
        font-size: 14px;
        color: #666;
        border-bottom: 2px solid transparent;
      }

      .tab-item.active {
        color: #1989fa;
        border-bottom-color: #1989fa;
      }

      .tab-item.more {
        display: flex;
        align-items: center;
      }

      /* 订单列表样式 */
      .order-list {
        flex: 1;
        overflow-y: auto;
        padding: 0 10px;
        height: 100vh;
      }

      /* 订单项样式 */
      .order-item {
        background-color: #fff;
        border-radius: 8px;
        margin-bottom: 10px;
        overflow: hidden;
      }

      .order-header {
        padding: 3px;
        border-bottom: 1px solid #f0f0f0;
        display: flex;
        justify-content: space-between;
        align-items: center;
      }

      .order-id {
        font-size: 15px;
        font-weight: 500;
        color: #333;
      }

      .order-status {
        font-size: 13px;
        padding: 2px 8px;
        border-radius: 12px;
      }

      .status-daitiaodu {
        background-color: #fff0f6;
        color: #f56c6c;
      }

      .status-yidiaodu {
        background-color: #f0f9ff;
        color: #409eff;
      }

      .status-yewancheng {
        background-color: #f6ffed;
        color: #67c23a;
      }
      .status-yihuidangshenhe {
        background-color: #fff0f6;
        color: #f56c6c;
      }
      .status-yishangchu {
        background-color: #fef0f0;
        color: #f56c6c;
      }
      .status-suoding {
        background-color: #f5f7fa;
        color: #909399;
      }
      .status-yizhuanghuo {
        background-color: #fff0f6;
        color: #f56c6c;
      }
      .status-caogao {
        background-color: #fff0f6;
        color: #f56c6c;
      }
      .status-defule {
        background-color: #fff0f6;
        color: #f56c6c;
      }

      /* 订单详情样式 - 重点修改：改为双列布局 */
      .order-detail {
        padding: 3px;
        font-size: 14px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        /* gap: 8px; */
      }

      .detail-row {
        display: flex;
      }

      .detail-label {
        color: #999;
        font-size: 12px;
        margin-bottom: 2px;
      }

      .detail-value {
        color: #333;
        font-size: 12px;
        word-break: break-all;
      }

      /* 订单操作样式 */
      .order-actions {
        border-top: 1px solid #f0f0f0;
        display: flex;
        justify-content: flex-end;
      }

      .edit-button {
        font-size: 13px;
        color: #1989fa;
        border: 1px solid #1989fa;
        border-radius: 4px;
        background-color: transparent;
      }

      /* 底部按钮样式 */
      .bottom-button {
        padding: 16px;
      }

      .add-order-button {
        width: 100%;
        background-color: #1989fa;
        color: #fff;
        border: none;
        border-radius: 24px;
        padding: 12px;
        font-size: 16px;
      }

      .van-cell {
        padding: 8px 6px;
      }

      /* 全局样式 */
      html,
      body {
        height: 100%;
        margin: 0;
        padding: 0;
        overflow-x: hidden;
        width: 100%;
      }

      #app {
        height: 100%;
        width: 100%;
        overflow-x: hidden;
      }
      .van-cell--clickable {
        text-align: right;
        color: #666;
      }
    </style>
  </head>

  <body>
    <div id="app">
      <van-popup v-model="showPicker.kehjcPicker" position="bottom">
        <van-picker
          show-toolbar
          :columns="kehjcPickerOptions"
          @confirm="onConfirm_kehjc"
          @cancel="showPicker.kehjcPicker = false"
        />
      </van-popup>
      <van-popup v-model="showPicker.zhdPicker" position="bottom">
        <van-picker
          show-toolbar
          :columns="zhdPickerOptions"
          @confirm="onConfirm_zhd"
          @cancel="showPicker.zhdPicker = false"
        />
      </van-popup>
      <van-popup v-model="showPicker.xhjcPicker" position="bottom">
        <van-picker
          show-toolbar
          :columns="xhjcPickerOptions"
          @confirm="onConfirm_xhjc"
          @cancel="showPicker.xhjcPicker = false"
        />
      </van-popup>
      <van-popup v-model="showPicker.cphPicker" position="bottom">
        <van-picker
          show-toolbar
          :columns="cphPickerOptions"
          @confirm="onConfirm_cph"
          @cancel="showPicker.cphPicker = false"
        />
      </van-popup>
      <van-popup v-model="showPicker.cpdmPicker" position="bottom">
        <van-picker
          show-toolbar
          :columns="cpdmPickerOptions"
          @confirm="onConfirm_cpdm"
          @cancel="showPicker.cpdmPicker = false"
        />
      </van-popup>
      <van-popup v-model="showPicker.sjiPicker" position="bottom">
        <van-picker
          show-toolbar
          :columns="sjiPickerOptions"
          @confirm="onConfirm_sji"
          @cancel="showPicker.sjiPicker = false"
        />
      </van-popup>
      <van-popup v-model="showPicker.xsyPicker" position="bottom">
        <van-picker
          show-toolbar
          :columns="xsyPickerOptions"
          @confirm="onConfirm_xsy"
          @cancel="showPicker.xsyPicker = false"
        />
      </van-popup>
      <van-popup v-model="showPicker.ddztPicker" position="bottom">
        <van-picker
          show-toolbar
          :columns="ddztPickerOptions"
          @confirm="onConfirm_ddzt"
          @cancel="showPicker.ddztPicker = false"
        />
      </van-popup>
      <van-popup v-model="showPicker.ddrqSPicker" position="bottom">
        <van-datetime-picker
          v-model="currentDate"
          type="datehour"
          title="选择年月日小时"
          :min-date="minDate"
          :max-date="maxDate"
          @confirm="onConfirm_ddrqS"
          @cancel="showPicker.ddrqSPicker = false"
        />
      </van-popup>
      <van-popup v-model="showPicker.ddrqEPicker" position="bottom">
        <van-datetime-picker
          v-model="currentDate"
          type="datehour"
          title="选择年月日小时"
          :min-date="minDate"
          :max-date="maxDate"
          @confirm="onConfirm_ddrqE"
          @cancel="showPicker.ddrqEPicker = false"
        />
      </van-popup>
      <van-popup v-model="showPicker.rqlxPicker" position="bottom">
        <van-picker
          show-toolbar
          :columns="rqlxPickerOptions"
          @confirm="onConfirm_rqlx"
          @cancel="showPicker.rqlxPicker = false"
        />
      </van-popup>

      <div class="page-container">
        <!-- 头部标题 -->
        <!-- <div class="header">
          <div class="header-title">运费订单</div>
        </div> -->
        <!-- 查询 -->
        <div style="position: relative">
          <van-collapse v-model="activeNames">
            <van-collapse-item title="更多" name="1">
              <div style="display: flex">
                <van-cell-group>
                  <van-field v-model="fromate.ddh" placeholder="订单号" />
                </van-cell-group>
                <van-cell-group>
                  <van-field v-model="fromate.ydh" placeholder="运单号" />
                </van-cell-group>
              </div>
              <div style="display: flex">
                <van-cell-group>
                  <van-field
                    readonly
                    clickable
                    name="picker"
                    :value="fromate.kehjc"
                    placeholder="客户简称"
                    @click="showPicker.kehjcPicker = true"
                  />
                </van-cell-group>
                <van-cell-group>
                  <van-field
                    readonly
                    clickable
                    name="picker"
                    :value="fromate.zhd"
                    placeholder="装货地"
                    @click="showPicker.zhdPicker = true"
                  />
                </van-cell-group>
              </div>
              <div style="display: flex">
                <van-cell-group>
                  <van-field
                    readonly
                    clickable
                    name="picker"
                    :value="fromate.xhjc"
                    placeholder="卸货简称"
                    @click="showPicker.xhjcPicker = true"
                  />
                </van-cell-group>
                <van-cell-group>
                  <van-field
                    readonly
                    clickable
                    name="picker"
                    :value="fromate.cph"
                    placeholder="车牌号"
                    @click="showPicker.cphPicker = true"
                  />
                </van-cell-group>
              </div>
              <div style="display: flex">
                <van-cell-group>
                  <van-field
                    readonly
                    clickable
                    name="picker"
                    :value="fromate.cpdm"
                    placeholder="产品代码"
                    @click="showPicker.cpdmPicker = true"
                  />
                </van-cell-group>
                <van-cell-group>
                  <van-field
                    readonly
                    clickable
                    name="picker"
                    :value="fromate.sji"
                    placeholder="司机"
                    @click="showPicker.sjiPicker = true"
                  />
                </van-cell-group>
              </div>
              <div style="display: flex">
                <van-cell-group>
                  <van-field
                    readonly
                    clickable
                    name="picker"
                    :value="fromate.xsy"
                    placeholder="销售员"
                    @click="showPicker.xsyPicker = true"
                  />
                </van-cell-group>
                <van-cell-group>
                  <van-field
                    readonly
                    clickable
                    name="picker"
                    :value="fromate.ddzt"
                    placeholder="订单状态"
                    @click="showPicker.ddztPicker = true"
                  />
                </van-cell-group>
              </div>
              <div style="display: flex">
                <van-cell-group>
                  <van-field
                    readonly
                    clickable
                    name="picker"
                    :value="fromate.rqlx"
                    placeholder="日期类型"
                    @click="showPicker.rqlxPicker = true"
                  />
                </van-cell-group>
              </div>
              <div style="display: flex">
                <van-cell-group>
                  <van-field
                    readonly
                    clickable
                    name="picker"
                    :value="fromate.ddrqS"
                    placeholder="日期起"
                    @click="showPicker.ddrqSPicker = true"
                  />
                </van-cell-group>
                <van-cell-group>
                  <van-field
                    readonly
                    clickable
                    name="picker"
                    :value="fromate.ddrqE"
                    placeholder="日期止"
                    @click="showPicker.ddrqEPicker = true"
                  />
                </van-cell-group>
              </div>

              <div style="text-align: right">
                <van-button type="warning" size="small" @click="resetquery"
                  >重置</van-button
                >
                <van-button type="info" size="small" @click="searchTable"
                  >查询</van-button
                >
              </div>
            </van-collapse-item>
          </van-collapse>
          <!-- 标签页 - 动态绑定active类 -->
          <div class="tabs-container">
            <div class="tabs-wrapper">
              <div
                :class="['tab-item', {active: activeTab === '全部'}]"
                @click="switchTab('全部')"
              >
                全部
              </div>
              <div
                :class="['tab-item', {active: activeTab === '待调度'}]"
                @click="switchTab('待调度')"
              >
                待调度
              </div>
              <div
                :class="['tab-item', {active: activeTab === '已调度'}]"
                @click="switchTab('已调度')"
              >
                已调度
              </div>
              <div
                :class="['tab-item', {active: activeTab === '已完成'}]"
                @click="switchTab('已完成')"
              >
                已完成
              </div>
            </div>
          </div>
        </div>
        <!-- 订单列表 -->
        <div class="order-list">
          <van-list
            v-model="loading"
            :finished="finished"
            finished-text="没有更多了"
            @load="onLoad"
          >
            <van-cell
              v-for="order in orderList"
              :key="order.SDLNID"
              class="order-item"
            >
              <div class="order-header">
                <div class="order-id" style="color: rgb(106 66 66)">
                  订单号:<span>{{order.SDLNID}}</span>
                </div>
                <div :class="['order-status', conffeijgg(order.SDNXTR)]">
                  {{DDZText[order.SDNXTR]}}
                </div>
              </div>
              <div class="order-detail">
                <div class="detail-row">
                  <div class="detail-label">客户简称:</div>
                  <div class="detail-value">{{order.SDAN8T}}</div>
                </div>
                <div class="detail-row">
                  <div class="detail-label">业务类型:</div>
                  <div class="detail-value">{{order.SDDCTO}}</div>
                </div>
                <div class="detail-row">
                  <div class="detail-label">客户订单号:</div>
                  <div class="detail-value">{{order.SDCUSDOC}}</div>
                </div>
                <div class="detail-row">
                  <div class="detail-label">订单日期:</div>
                  <div class="detail-value">{{order.SDDRQJ}}</div>
                </div>
                <div class="detail-row">
                  <div class="detail-label">产品:</div>
                  <div class="detail-value">{{order.SDLITM}}</div>
                </div>
                <div class="detail-row">
                  <div class="detail-label">订单数量:</div>
                  <div class="detail-value">{{order.SDUORG}}</div>
                </div>
                <div class="detail-row">
                  <div class="detail-label">装货地点:</div>
                  <div class="detail-value">{{order.SouAddName}}</div>
                </div>
                <div class="detail-row">
                  <div class="detail-label">要求装货时间:</div>
                  <div class="detail-value">{{order.SouRDT}}</div>
                </div>
                <div class="detail-row">
                  <div class="detail-label">卸货地点:</div>
                  <div class="detail-value">{{order.SDPA8T}}</div>
                </div>
                <div class="detail-row">
                  <div class="detail-label">要求卸货时间:</div>
                  <div class="detail-value">{{order.UnloadDT}}</div>
                </div>
              </div>
              <div class="order-actions">
                <button class="edit-button" @click="editOrder(order.SDNXTR)">
                  编辑
                </button>
              </div>
            </van-cell>
          </van-list>
          <!-- 无数据时显示 -->
          <!-- <div
            v-if="filteredOrders.length === 0"
            style="text-align: center; padding: 40px 0; color: #999"
          >
            暂无订单数据
          </div> -->
        </div>

        <!-- 底部按钮 -->
        <div class="bottom-button">
          <button class="add-order-button" @click="addOrder">
            新增运费订单
          </button>
        </div>
      </div>
    </div>
    <script src="https://wxapp.jsadf.com/vendor/vue2.prod.bundle.js"></script>
    <script src="https://pyzl-static.oss-cn-guangzhou.aliyuncs.com/vendor/vant.2.15.54.min.js"></script>
    <script>
      function getCurrentMonthFirstAndLastDay() {
        // 获取当前日期
        const now = new Date();
        const year = now.getFullYear();
        const month = now.getMonth();

        // 获取当月第一天并设置时间为00:00:00
        const firstDay = new Date(year, month, 1);
        firstDay.setHours(0, 0, 0, 0);

        // 获取当月最后一天并设置时间为23:59:59
        const lastDay = new Date(year, month + 1, 0);
        lastDay.setHours(23, 59, 59, 999); // 999表示毫秒，确保包含当天的最后一刻

        // 返回格式化的日期字符串
        return {
          firstDay: firstDay.toString(),
          lastDay: lastDay.toString(),
        };
      }
      function formatDateRange(dateArray) {
        // 定义中文月份名称
        const monthNames = [
          "01",
          "02",
          "03",
          "04",
          "05",
          "06",
          "07",
          "08",
          "09",
          "10",
          "11",
          "12",
        ];

        // 转换单个日期的函数
        const formatDate = (dateStr) => {
          const date = new Date(dateStr);
          const year = date.getFullYear();
          const month = monthNames[date.getMonth()]; // 月份从0开始，需转换
          const day = date.getDate().toString().padStart(2, "0"); // 确保两位日期
          return `${year}/${month}/${day}`;
        };

        // 处理输入数组
        return dateArray.map(formatDate);
      }
      function convertDateFormat(inputDate) {
        const date = new Date(inputDate);
        const year = date.getFullYear();
        const month = date.getMonth() + 1;
        const day = date.getDate();

        // 补零函数：确保时间单位始终为两位数
        const padZero = (num) => num.toString().padStart(2, "0");

        const hours = padZero(date.getHours());
        const minutes = padZero(date.getMinutes());
        const seconds = padZero(date.getSeconds());

        return `${year}/${month}/${day} ${hours}:${minutes}:${seconds}`;
      }

      // 辅助函数：将.NET日期格式转换为年月日格式
      function formatDotNetDate(dotNetDate, is) {
        if (!dotNetDate || typeof dotNetDate !== "string") {
          return "";
        }

        try {
          // 提取时间戳数字部分
          const timestampMatch = dotNetDate.match(/\d+/);
          if (timestampMatch && timestampMatch.length > 0) {
            const timestamp = parseInt(timestampMatch[0]);
            const date = new Date(timestamp);

            // 格式化日期为YYYY-MM-DD HH:mm:ss格式
            const year = date.getFullYear();
            const month = String(date.getMonth() + 1).padStart(2, "0");
            const day = String(date.getDate()).padStart(2, "0");
            const hours = String(date.getHours()).padStart(2, "0");
            const minutes = String(date.getMinutes()).padStart(2, "0");
            const seconds = String(date.getSeconds()).padStart(2, "0");

            if (is) {
              return `${year}-${month}-${day}`;
            } else {
              return `${year}-${month}-${day} ${hours}:${minutes}`;
              // return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
            }
          }
        } catch (error) {
          console.error("日期格式转换失败:", error);
        }

        return dotNetDate; // 如果转换失败，返回原始值
      }
      Vue.use(vant.Icon);
      Vue.use(vant.Toast);
      new Vue({
        el: "#app",
        data() {
          return {
            minDate: new Date(2020, 0, 1),
            maxDate: new Date(2025, 10, 1),
            currentDate: new Date(),
            activeTab: "全部",
            activeNames: [],
            filteredOrders: [],
            loading: false,
            finished: false,
            fromate: {
              ddh: undefined,
              ydh: undefined,
              kehjc: undefined,
              zhd: undefined,
              xhjc: undefined,
              cph: undefined,
              cpdm: undefined,
              sji: undefined,
              xsy: undefined,
              ddzt: undefined,
              ddrqS: undefined,
              ddrqE: undefined,
              rqlx: "订单日期",
            },
            showPicker: {
              kehjcPicker: false,
              zhdPicker: false,
              xhjcPicker: false,
              cphPicker: false,
              cpdmPicker: false,
              sjiPicker: false,
              xsyPicker: false,
              ddztPicker: false,
              ddrqSPicker: false,
              ddrqEPicker: false,
              rqlxPicker: false,
            },

            kehjcPickerOptions: [],
            zhdPickerOptions: [],
            xhjcPickerOptions: [],
            cphPickerOptions: [],
            cpdmPickerOptions: [],
            sjiPickerOptions: [],
            xsyPickerOptions: [],
            rqlxPickerOptions: ["订单日期", "装货日期", "卸货日期"],
            ddztPickerOptions: [
              "草稿",
              "锁定",
              // "未调度",
              // "已调度",
              "已装货",
              // "已完成",
              "已回单审核",
              "已删除",
            ],
            Option_All: {},
            orderList: [],
            DDZText: {
              99: "草稿",
              0: "锁定",
              1: "未调度",
              2: "已调度",
              3: "已装货",
              4: "已完成",
              5: "已回单审核",
              "-1": "已删除",
            },
            pagination: {
              page: 1,
              rows: 10,
            },
          };
        },
        computed: {},
        created() {
          this.getCustomerC(); //获取下拉
          const result = getCurrentMonthFirstAndLastDay();
          this.fromate.ddrqS = convertDateFormat(result.firstDay);
          this.fromate.ddrqE = convertDateFormat(result.lastDay);
        },
        methods: {
          onLoad() {
            console.log("触底");
            this.loadOrderData();
            this.pagination.rows += 10;
          },
          conffeijgg(status) {
            if (status == 99) {
              return "status-caogao";
            } else if (status == 0) {
              return "status-suoding";
            } else if (status == 1) {
              return "status-daitiaodu";
            } else if (status == 2) {
              return "status-yidiaodu";
            } else if (status == 3) {
              return "status-yizhuanghuo";
            } else if (status == 4) {
              return "status-yewancheng";
            } else if (status == 5) {
              return "status-yihuidangshenhe";
            } else if (status == -1) {
              return "status-yishangchu";
            } else {
              return "status-defule";
            }
          },
          onConfirm_kehjc(value) {
            this.fromate.kehjc = value;
            this.showPicker.kehjcPicker = false;
          },
          onConfirm_zhd(value) {
            this.fromate.zhd = value;
            this.showPicker.zhdPicker = false;
          },
          onConfirm_xhjc(value) {
            this.fromate.xhjc = value;
            this.showPicker.xhjcPicker = false;
          },
          onConfirm_cph(value) {
            this.fromate.cph = value;
            this.showPicker.cphPicker = false;
          },
          onConfirm_cpdm(value) {
            this.fromate.cpdm = value;
            this.showPicker.cpdmPicker = false;
          },
          onConfirm_sji(value) {
            this.fromate.sji = value;
            this.showPicker.sjiPicker = false;
          },
          onConfirm_xsy(value) {
            this.fromate.xsy = value;
            this.showPicker.xsyPicker = false;
          },
          onConfirm_ddzt(value) {
            this.fromate.ddzt = value;
            this.showPicker.ddztPicker = false;
          },
          onConfirm_ddrqS(value) {
            this.fromate.ddrqS = convertDateFormat(value);
            this.showPicker.ddrqSPicker = false;
          },
          onConfirm_ddrqE(value) {
            this.fromate.ddrqE = convertDateFormat(value);
            this.showPicker.ddrqEPicker = false;
          },
          onConfirm_rqlx(value) {
            this.fromate.rqlx = value;
            this.showPicker.rqlxPicker = false;
          },

          // 切换标签页
          switchTab(tab) {
            this.activeTab = tab;
            // 根据选择的标签加载对应状态的订单数据
            this.loadOrderData();
          },

          // 显示更多标签
          showMoreTabs() {
            vant.Toast("显示更多标签");
            // 可以实现一个弹出层显示更多的标签选项
          },
          //查询
          searchTable() {
            this.pagination.rows = 10;
            this.finished = false;
            this.loadOrderData();
          },
          //重置查询
          resetquery() {
            this.fromate = {
              kehjc: undefined,
              zhd: undefined,
              xhjc: undefined,
              cph: undefined,
              cpdm: undefined,
              sji: undefined,
              xsy: undefined,
              ddzt: undefined,
              ddrqS: undefined,
              ddrqE: undefined,
              rqlx: "订单日期",
            };
            this.loadOrderData();
          },
          // 编辑订单
          editOrder(orderId) {
            // 跳转到订单编辑页面或打开编辑弹窗
            location.href = "/tmsHtml/yunAdd.html?mode=edit&id=" + orderId;
          },

          // 新增订单
          addOrder() {
            location.href = "/tmsHtml/yunAdd.html?mode=add";
          },
          //请求下拉
          async getCustomerC() {
            //客户简称
            const res = await axios.post(
              "https://www.51yunmai.com/CombBox/GetCustomerC?id=1",
              {},
              {}
            );
            if (res.status === 200) {
              this.Option_All.KHJC = res.data;
              this.kehjcPickerOptions = res.data.map(
                (item) => item.ADD_SearchCode
              );
            }
            //装货地
            const res2 = await axios.post(
              "https://www.51yunmai.com/CombBox/GetSouShortName?type=装货地点",
              {},
              {}
            );
            if (res2.status === 200) {
              this.Option_All.ZHD = res2.data;
              this.zhdPickerOptions = res2.data.map((item) => item.SearchCode);
            }
            //卸货简称
            const res3 = await axios.post(
              "https://www.51yunmai.com/CombBox/GetCustomer?id=1",
              {},
              {}
            );
            if (res3.status === 200) {
              this.Option_All.XHJC = res3.data;
              this.xhjcPickerOptions = res3.data.map(
                (item) => item.ADD_SearchCode
              );
            }
            //车牌号
            const res4 = await axios.post(
              "https://www.51yunmai.com/CombBox/GetTruck?id=1",
              {},
              {}
            );
            if (res3.status === 200) {
              this.Option_All.CPH = res4.data;
              this.cphPickerOptions = res4.data.map(
                (item) => item.EQ_TruckNumber
              );
            }
            //产品代码
            const res5 = await axios.post(
              "https://www.51yunmai.com/CombBox/GetSDLITM?id=1",
              {},
              {}
            );
            if (res5.status === 200) {
              this.Option_All.CPDM = res5.data;
              this.cpdmPickerOptions = res5.data.map((item) => item.SDLITM);
            }
            //司机
            const res6 = await axios.post(
              "https://www.51yunmai.com/CombBox/GetAllDriver?id=1",
              {},
              {}
            );
            if (res6.status === 200) {
              this.Option_All.SJI = res6.data;
              this.sjiPickerOptions = res6.data.map((item) => item.D_Name);
            }
            //销售代表
            const res7 = await axios.post(
              "https://www.51yunmai.com/CombBox/Salesperson",
              {},
              {}
            );
            if (res7.status === 200) {
              this.Option_All.XSY = res7.data;
              this.xsyPickerOptions = res7.data.map((item) => item.U_Name);
            }
          },

          // 请求列表123
          loadOrderData(status = "all") {
            // 这里可以添加从服务器获取订单数据的逻辑
            let f = this.fromate;
            // 客户简称按id查询
            let kejfi = undefined;
            if (f.kehjc) {
              kejfi = this.Option_All.KHJC.find(
                (item) => item.ADD_SearchCode === f.kehjc
              )?.ADD_Description;
            }
            // 卸货简称按id查询
            let fji = undefined;
            if (f.xhjc) {
              fji = this.Option_All.XHJC.find(
                (item) => item.ADD_SearchCode === f.xhjc
              )?.ADD_Description;
            }
            // 销售员按id查询
            let feid = undefined;
            if (f.xsy) {
              feid = this.Option_All.XSY.find(
                (item) => item.U_Name === f.xsy
              )?.U_Username;
            }
            // 日期类型
            let DateType = 0;
            if (f.rqlx === "卸货日期") {
              DateType = 2;
            } else if (f.rqlx === "装货日期") {
              DateType = 1;
            } else {
              DateType = 0;
            }
            //状态请求
            let zhuangtai = undefined;
            if (this.activeTab === "待调度") {
              zhuangtai = 2;
            } else if (this.activeTab === "已调度") {
              zhuangtai = 3;
            } else if (this.activeTab === "已完成") {
              zhuangtai = "已完成";
            } else {
              zhuangtai = f.ddzt || undefined;
            }
            const submitData = {
              SDLNID: f.ddh,
              TruckDoc: f.ydh,
              SDAN8: kejfi,
              SouAddName: f.zhd,
              SDPA8: fji,
              TruckNumber: f.cph,
              SDLITM: f.cpdm,
              Driver1: f.sji,
              Salesperson: feid,
              SDDRQJ: f.ddrqS,
              SDTRDJ: f.ddrqE,
              // SDDRQJ: "2025/9/11 0:00:00",
              // SDTRDJ: "2025/9/19 0:00:00",
              day: 0,
              SDDCTO: 0,
              Type: zhuangtai,
              DateType,
              // SDNXTR: f.ddzt,
              page: this.pagination.page,
              rows: this.pagination.rows,
            };
            try {
              axios
                .post(
                  "https://www.51yunmai.com/WeiXinOrder/Search",
                  submitData,
                  {
                    headers: {
                      "Content-Type": "application/x-www-form-urlencoded",
                    },
                  }
                )
                .then((res) => {
                  if (res.status === 200) {
                    let newOrderList = res.data.rows.map((order) => {
                      if (order.SDDRQJ) {
                        order.SDDRQJ = formatDotNetDate(order.SDDRQJ, true);
                        order.SouRDT = formatDotNetDate(order.SouRDT);
                        order.UnloadDT = formatDotNetDate(order.UnloadDT);
                      }
                      return order;
                    });
                    this.orderList = newOrderList;
                    console.log("打印结果~~", this.orderList);
                    this.loading = false;
                    if (this.orderList.length >= res.data.total) {
                      this.finished = true;
                    }
                  }
                });
            } catch (error) {
              console.error("请求失败", error);
              vant.Toast("请求失败");
            }

            // console.log(`加载${status}订单数据`);
            // 在实际应用中，这里应该是一个API请求
            // 为了演示，我们使用已有的静态数据
            // vant.Toast(`已切换到${this.getStatusText(status)}`);
          },
        },
      });
    </script>
  </body>
</html>
